<template>
  <el-dialog
    title="积分记录"
    :visible="value"
    width="700px"
    custom-class="dialog-box"
    @close="onClose"
    @open="onOpen"
    :close-on-click-modal="false"
    :append-to-body="true"
  >
    <table class="table-box">
      <thead>
        <tr>
          <th>变动类型</th>
          <th>时间</th>
          <th>变动积分</th>
          <th>变动后积分</th>
          <th>备注</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item,index) in tableList" :key="index">
          <td>{{item.source | changeSource}}</td>
          <td>{{item.gmtCreate}}</td>
          <td>{{item.changeNum}}</td>
          <td>{{item.afterNum}}</td>
          <td>{{item.desc}}</td>
        </tr>
        <tr v-if="tableList.length<1">
          <td colspan="4" style="text-align:center">暂无数据</td>
        </tr>
      </tbody>
    </table>
    <br />
    <pager v-model="pager" @change-pagenum="getData"></pager>
  </el-dialog>
</template>
<script>
export default {
  props: ["value", "curItem"],
  data() {
    return {
      tableList: [],
      pager: { pageSize: 10, pageNum: 1, total: 0 }
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData(type) {
      let th = this;
      if (type == -1) {
        th.pager.pageNum = 1;
        th.pager.total = 0;
      }
      let j = {
        patientId: th.curItem.patientId,
        hpId: th.adminUser.hpId
      };
      Object.assign(j, th.pager);
      th.showLoading();
      th.$api.getIntegralRecord(j).then(res => {
        if (res.executed) {
          th.tableList = res.dataBody.list;
          th.pager.total = res.dataBody.total;
        } else {
          th.tableList = [];
          th.pager.total = 0;
        }
        th.showLoading(false);
      });
    },
    onClose() {
      let th = this;
      th.$emit("input", false);
    },
    onOpen(){

    }
  }
};
</script>
